package com.dime.physical.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import com.dime.physical.domain.dto.SearchReportCompanyDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.dime.physical.domain.DimePhysicalMrMain;
import com.dime.physical.service.IDimePhysicalMrMainService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 总检主Controller
 * 
 * @author ruoyi
 * @date 2023-10-10
 */
@RestController
@RequestMapping("/main")
public class DimePhysicalMrMainController extends BaseController
{
    @Autowired
    private IDimePhysicalMrMainService dimePhysicalMrMainService;

    /**
     * 查询总检主列表
     */
    @RequiresPermissions("physical:main:list")
    @GetMapping("/list")
    public TableDataInfo list(DimePhysicalMrMain dimePhysicalMrMain)
    {
        startPage();
        List<DimePhysicalMrMain> list = dimePhysicalMrMainService.selectDimePhysicalMrMainList(dimePhysicalMrMain);
        return getDataTable(list);
    }


    /**
     * 总结报告查询单位列表
     */
    @PostMapping("/companyList")
    public AjaxResult companylist(@RequestBody SearchReportCompanyDto searchReportCompanyDto)
    {
        startPage();
        List<DimePhysicalMrMain> list = dimePhysicalMrMainService.selectDimePhysicalMrMainReportList(searchReportCompanyDto);
        return success(list);
    }

    /**
     * 导出总检主列表
     */
    @RequiresPermissions("physical:main:export")
    @Log(title = "总检主", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DimePhysicalMrMain dimePhysicalMrMain)
    {
        List<DimePhysicalMrMain> list = dimePhysicalMrMainService.selectDimePhysicalMrMainList(dimePhysicalMrMain);
        ExcelUtil<DimePhysicalMrMain> util = new ExcelUtil<DimePhysicalMrMain>(DimePhysicalMrMain.class);
        util.exportExcel(response, list, "总检主数据");
    }

    /**
     * 获取总检主详细信息
     */
    @RequiresPermissions("physical:main:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(dimePhysicalMrMainService.selectDimePhysicalMrMainById(id));
    }

    /**
     * 新增总检主
     */
    @RequiresPermissions("physical:main:add")
    @Log(title = "总检主", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DimePhysicalMrMain dimePhysicalMrMain)
    {
        return toAjax(dimePhysicalMrMainService.insertDimePhysicalMrMain(dimePhysicalMrMain));
    }

    /**
     * 修改总检主
     */
    @RequiresPermissions("physical:main:edit")
    @Log(title = "总检主", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DimePhysicalMrMain dimePhysicalMrMain)
    {
        return toAjax(dimePhysicalMrMainService.updateDimePhysicalMrMain(dimePhysicalMrMain));
    }

    /**
     * 删除总检主
     */
    @RequiresPermissions("physical:main:remove")
    @Log(title = "总检主", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(dimePhysicalMrMainService.deleteDimePhysicalMrMainByIds(ids));
    }
}
